package com.blue.bluecode;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ProgressBar;


public class ProgressBarActivity extends Activity {

    private ProgressBar pgb4;
    private int mProgressBarStatus = 0;
    private Handler mHandler = new Handler();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_progress_bar);
        getActionBar().setDisplayHomeAsUpEnabled(true);

        pgb4 = (ProgressBar) findViewById(R.id.progressBar4);
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (mProgressBarStatus < 100){
                    mProgressBarStatus += 1;
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    mHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            pgb4.setProgress(mProgressBarStatus);
                        }
                    });
                }
            }
        }).start();
    }

}
